package com.xl.baseMethod;

import lombok.extern.slf4j.Slf4j;

import static java.lang.Thread.sleep;

/**
 * JdkVersion: 1.8
 * Author: lei·xie
 * Created: 2024/8/5 0002 10:22
 * Description: 基本方法 join
 */
@Slf4j(topic = "b.Test6")
public class ThreadDemo06 {
    static int r = 0;
    public static void main(String[] args) {
        test1();
    }

    private static void test1() {
        log.debug("开始");
        Thread t1 = new Thread(() -> {
            log.debug("开始");
            try {
                sleep(3000);
            } catch (InterruptedException e) {
                throw new RuntimeException(e);
            }
            log.debug("结束");
            r = 10;
        },"t1");
        t1.start();
        try {
            t1.join();
            //t1.join(1000);
        } catch (InterruptedException e) {
            throw new RuntimeException(e);
        }
        log.debug("结果为：{}",r);
        log.debug("结束");
    }
}
